<template>
  <!-- 暂停 -->
  <a-modal
    :width="500"
    :visible="stopOrderVisible"
    @ok="handleStopOrderSubmit"
    @cancel="handleStopOrderClose"
    cancelText="关闭"
    title="暂停"
  >
    <a-spin :spinning="confirmLoading">
      <a-form layout="horizontal">
        <a-row :gutter="24">
          <a-col>
            <a-form-model-item
              label="暂停原因："
              :label-col="{ span: 5 }"
              :wrapper-col="{ span: 16 }"
              prop="reasonSuspension"
              :rules="$valid.required"
            >
              <a-select
                v-model="stopOrder.reasonSuspension"
                placeholder="请选择暂停原因"
                @change="forceUpdate"
              >
                <a-select-option
                  v-for="item in this.$sysDictOptions('reasonSuspension')"
                  :key="item.k"
                  :value="item.k"
                >
                  {{ item.v }}
                </a-select-option>
              </a-select>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col>
            <a-form-model-item
              label="备注："
              :label-col="{ span: 5 }"
              :wrapper-col="{ span: 16 }"
              prop="pauseRemarks"
            >
              <a-input v-model="stopOrder.pauseRemarks" type="textarea" />
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form>
    </a-spin>
  </a-modal>
</template>

<script>
import moment from 'moment'
import { getAction, postAction, deleteAction } from '@/api/manage'
import { getCompanyList } from '@/api/api'
import WImageUpload from '@/components/WxImageUpload/WImageUpload'
import WFileUpload from '@/components/WxFileUpload/WFileUpload.vue'

export default {
  name: 'StopOrderForm',
  components: {
    WImageUpload,
    WFileUpload,
  },
  computed: {},
  data() {
    return {
      confirmLoading: false,
      workGroupTree: [],
      stopOrderVisible: false,
      stopOrder: {
        ids: undefined,
        reasonSuspension: undefined,
        pauseRemarks: undefined,
      },
      current: 0,
      url: {
        update: '/system/devMaintenance/update',
      },

      createByList: [],
    }
  },
  created() {},
  methods: {
    forceUpdate() {
      this.$forceUpdate()
    },

    moment,

    //START 暂停
    handleStopOrder(id) {
      this.stopOrderVisible = true
      this.stopOrder = {}
      this.stopOrder.ids = id
    },

    handleStopOrderSubmit() {
      if (!this.stopOrder.reasonSuspension) {
        this.$message.error('请选择暂停原因')
        return
      }

      this.stopOrderVisible = true
      this.stopOrder.workOrderStatus = '3'
      postAction(this.url.update, this.stopOrder).then((resp) => {
        this.$message.success('暂停成功')
        this.handleStopOrderClose()
      })
    },
    handleStopOrderClose() {
      this.stopOrderVisible = false
      this.stopOrder = {}
      this.$emit('close')
    },
    //END 暂停
  },
}
</script>
<style scoped>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Microsoft YaHei', sans-serif;
  background-color: #f0f2f5;
  color: #333;
  padding: 20px;
}
</style>
